import Router from "vue-router"
import Vue from "vue"

Vue.use(Router);  // 全局挂载 router-view router-link 组件 
// 在this中添加$router $route

const router = new Router({
    mode: "history",
    routes:[
        {
            path:'/login',
            meta:{
                title:'登录'
            },
            component:() =>import('@/views/Login')
        },
        {
            path:'/index',
            meta:{
                title:'首页'
            },
            component:() =>import('@/views/Index')
        }
       
    ]
})

router.beforeEach((to,from,next) => {
    document.title = to.meta?.title
    next();
})

export default router;
